package com.msos.service.GetAccountService;

import com.msos.dao.getAccountDao.GetAccountDao;
import com.msos.model.customer.Customer;

import java.sql.SQLException;

/**
 * @ClassName: GetAccountService
 * @Description: TODO
 * @Author: hsx
 * @Date: 2022/4/12 22:14
 * @Version: v1.0
 */
public class GetAccountService {
    GetAccountDao getAccountDao = new GetAccountDao();

    //查询登录账户的余额
    public Customer getAccount(Customer customer) {
        try {
            return getAccountDao.getCustomerByPhone(customer.getPhone());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    //查询指定手机号的余额信息
    public Customer getAccountByUP(String phone, String password) {
        try {
            Customer customer = getAccountDao.getCustomerByPhone(phone);
            if (customer == null) {
                return null;
            } else {
                if (customer.getPassword().equals(password)) {
                    return customer;
                } else {
                    return null;
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
